//
//  NMNotificationRequestCalendar.m
//  NotificationMe
//
//  Created by max on 2018/12/16.
//  Copyright © 2018年 dayang. All rights reserved.
//

#import "NMNotificationRequestCalendar.h"

@implementation NMNotificationRequestCalendar
+ (UNNotificationRequest *)requestWithContent:(NSDictionary *)content {
    UNMutableNotificationContent *nContent = [[UNMutableNotificationContent alloc] init];
    nContent.title = content[@"title"];
    nContent.body = content[@"body"];
    if ([content[@"sound"] boolValue]) {
        nContent.sound = [UNNotificationSound defaultSound];
    }
    BOOL repeat = [content[@"repeat"] boolValue];
    NSDateComponents *components = content[@"components"];
    UNCalendarNotificationTrigger *trigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:components repeats:repeat];
    return [UNNotificationRequest requestWithIdentifier:[self identifier]
                                                content:nContent trigger:trigger];
}
@end
